
/**
 * 获取url传参
 * @return 一个不会为空的对象，对象的属性为参数名，值为参数值
 */
function getUrlParam() {
    var param = {};

    //当前窗口url ？及之后的部分
    var search = location.search;

    //没有参数部分
    if (!search) {
        return param;
    }

    //截取?后的字符串
    search = search.substring(1);

    //分割参数
    var params = search.split('&');

    //将参数名和参数值存入对象
    for (var i = 0; i < params.length; i++) {

        //符号&后有参数
        if (!params[i]) {
            continue;
        }

        //用=分割
        var keyValue = params[i].split('=');

        // 等号后有参数值
        if (keyValue.length > 1) {
            param[keyValue[0]] = keyValue[1];
        }
    }
    return param;
}

/** -----------------------------------
 *     JS - 前端生成 UUID 四种方法
 * https://blog.51cto.com/u_10980859/5303307
 **/
function getUuid(len, radix) {
    var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
    var uuid = [], i;
    radix = radix || chars.length;

    if (len) {
        // Compact form
        for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random()*radix];
    } else {
        // rfc4122, version 4 form
        var r;

        // rfc4122 requires these characters
        uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
        uuid[14] = '4';

        // Fill in random data.  At i==19 set the high bits of clock sequence as
        // per rfc4122, sec. 4.1.5
        for (i = 0; i < 36; i++) {
            if (!uuid[i]) {
                r = 0 | Math.random()*16;
                uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
            }
        }
    }

    return uuid.join('');
}